<?php
class dao {

    public function connexion() {

        $utilisateur = 'root';
        $pass = '';
        $source = 'mysql:host=localhost;dbname=projetweb';

        try {
            return $connexion = new PDO($source, $utilisateur, $pass);
        } catch (PDOExeption $ex) {
            die("impossible de se connecter a la base de donnee : " . $ex->getMessage());
        }
    }

}


class requete extends dao {
    
    private $type;
    private $nom;
    private $prenom;
    private $identifiant;
    private $mdp;
    private $mail;

    
    
    public function __construct($type,$nom, $prenom,$identifiant,$mdp,$mail) {
     
        $this->type = $type;
        $this->nom = $nom;
        $this->prenom= $prenom;
        $this->identifiant=$identifiant;
        $this->mdp=$mdp;
        $this->mail=$mail;

        

        
    }
          public function modifierpersonne()
        {
        $req = " UPDATE personne SET TYPE ='" . $this->type . "', NOM = '" . $this->nom . "', PRENOM = '" . $this->prenom . "', IDENTIFIANT ='".$this->identifiant."', MOT_DE_PASSE='" . $this->mdp . "', MAIL = '" . $this->mail . "' WHERE IDENTIFIANT = '".$this->identifiant."'";

        try {
        $this->connexion()->exec($req);
        return 1;
        } catch (PDOException $ex) {
            die("erreur sql : " . $ex->getMessage());
            return 2;
        }
    }
    
   
    }
?>
